package com.org.cys.service.impl.${package};

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.org.cys.dao.base.IGeneralDao;
import com.org.cys.pojo.base.Page;
import com.org.cys.service.${package}.${entityName}Service;
import com.org.cys.util.PageData;


/**
 *	${entityComment} Service实现类
 */
@Service("${entityNameSmall}ServiceImpl")
public class ${entityName}ServiceImpl implements ${entityName}Service {
  
  @Resource(name="generalDao")
  private IGeneralDao generalDao;
  
  public static String XMLMapper = "${entityName}Mapper";
  
 /**
  * 保存${entityName}
  * @param PageData
  * @throws Exception
  * */
  @Override
  public void save(PageData pd) throws Exception{
	  generalDao.save(XMLMapper+".save",pd);
  }
  
<#list dataList as var>	
 /**
   * 根据${var.newColumn}批量插入${entityName}
   * @param ${var.newColumn} ${var.comment}
   * @param dataList 数据集
   * */
  @Override
  public void saveBatchBy${var.newColumnBigger}(List<PageData> dataList,Long ${var.newColumn}) throws Exception{
	  deleteBy${var.newColumnBigger}(${var.newColumn});//先删除之前关联数据再重新添加新的关联数据
	  generalDao.batchSave(XMLMapper+".saveBatch", dataList);
  }
  
</#list>
<#list dataList as var>	
 /**
  * 根据${var.newColumn}获取${entityName}
  * @param ${var.newColumn} ${var.comment}
  * @throws Exception 
  * */
  @Override
  public List<PageData> getListBy${var.newColumnBigger}(Long ${var.newColumn}) throws Exception{
	  return (List<PageData>)generalDao.findForList(XMLMapper+".getListBy${var.newColumnBigger}", ${var.newColumn});
  }
  
</#list>
<#list dataList as var>	
 /**
   * 根据${var.newColumn}删除${entityName}
   * @param ${var.newColumn} ${var.comment}
   * @throws Exception  
   * */
  public void deleteBy${var.newColumnBigger}(Long ${var.newColumn}) throws Exception{
	  generalDao.delete(XMLMapper+".deleteBy${var.newColumnBigger}",${var.newColumn});
  }

</#list>
  
}